<template>
  <div class="m-products-list">
    <ul>
      <li :class="{ 's-nav-active': item.active }" v-for="item in nav" :key="item.key">
        {{ item.name }}
      </li>
    </ul>
    <el-row>
      <m-item v-for="(item, index) in productList" :key="index" :meta="item" />
    </el-row>
  </div>
</template>

<script>
import MItem from './item.vue';
import api from '@/api/index';

export default {
  data() {
    return {
      nav: [
        {
          key: 's-default',
          name: '智能排序',
          active: true,
        },
        {
          key: 's-price',
          name: '价格最低',
          active: false,
        },
        {
          key: 's-score',
          name: '人气最高',
          active: false,
        },
        {
          key: 's-comment',
          name: '评价最高',
          active: false,
        },
      ],
      productList: [],
    };
  },
  created() {
    api.goodsList().then((res) => {
      this.productList = res.data.data;
    });
  },
  components: {
    MItem,
  },
};
</script>

<style lang="scss" scoped>
@import '@/assets/css/products/index.scss';
@import '@/assets/css/products/list.scss';
</style>
